﻿using MediatR;
using SystemWFH.API.Application.Command.EquipmentCommand;
using SystemWFH.Infrstructer.Impl;
using SystemWFH.Infrstructer.Interface;

namespace SystemWFH.API.Application.CommandHandlers.EquipmentCommandHandler
{
    public class EquipmentDeletesCommandHandler : IRequestHandler<EquipmentDeletesCommand, int>
    {
        /// <summary>
        /// 服务
        /// </summary>
        private readonly IEquipmentRepository equipmentRepository;
        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="equipmentRepository">服务</param>
        public EquipmentDeletesCommandHandler(IEquipmentRepository equipmentRepository)
        {
            this.equipmentRepository = equipmentRepository;
        }
        public async Task<int> Handle(EquipmentDeletesCommand request, CancellationToken cancellationToken)
        {
            var list = await equipmentRepository.GetValue(request.equipmentId);
            list.IsDelete = true;
            list.DelectTime = DateTime.Now.ToUniversalTime();
            list.DelectName = "李明";
            return await equipmentRepository.UpdateAsync(list);
        }
    }
}
